Working with Documents on the Cloud

Ian Hojnicki

Wolfram Research

Overview

Quick Overview at the UI for working with the Cloud documents

Current CloudObject aware Notebook functions

Future Plans

v10 Wolfram Cloud User Interfaces

Open Dialog

Save Dialog

Activity Monitor

Cloud Document Notifications

Wolfram Cloud Error Notification Docked Cell

Missing or Disconnected Internet connection

An error occurred while saving the notebook contents back to the cloud

CloudObject Aware Functions

NotebookOpen

Programmatically open documents on the cloud

NotebookSave

One argument form

The one argument form is asynchronous (* the data might not have completely made it to the server before the function finishes *)

Two argument form

The two argument form does not accept a CloudObject as a destination

NotebookInformation

New rules to support Wolfram Cloud documents

StorageSystem - Indicates whether the notebook is stored on the cloud or locally

Uri - The CloudObject that backs this particular notebook

{"Uri"->CloudObject[MouseOver],"FileModificationTime"->3.622728659`*^9,"WindowTitle"->"NotebookInformation.nb","MemoryModificationTime"->3.622728662481147`*^9,"ModifiedInMemory"->True,"StorageSystem"->"WolframCloud","DocumentType"->"Notebook","MIMEType"->"application/mathematica","StyleDefinitions"->{(NotebookObjectMissing[FrontEndObject[LinkObject["igy63_shm", 3, 1]], 4])}}

A Quick Look into the Future

**Everything here should be available in a future release**

NotebookSave[] cont...

For performance reasons, the UI actually has a queue of Cloud related operations.  So how can I tell when it is finished?

CurrentValue[“PendingWolframCloudTasks”]

Returns whether there are tasks in the Wolfram Cloud task queue

For all notebooks:

CurrentValue[$FrontEnd, "PendingWolframCloudTasks"]

CurrentValue[$FrontEnd, {"PendingWolframCloudTasks", "Open"}]

CurrentValue[$FrontEnd, {"PendingWolframCloudTasks", "Save"}]

For a specific notebook:

CurrentValue[nb_NotebookObject, "PendingWolframCloudTasks"]

CurrentValue[nb_NotebookObject, {"PendingWolframCloudTasks", "Save"}]

Example

assyncnb = NotebookOpen[FileNameJoin[{CloudDirectory[], "Tech Conference 2014", "AsyncExample.nb"}], Visible->False];
NotebookSave[assyncnb];
Pane@Style[PaneSelector[{False->"Status: Idle",True->"Status: Saving..."},Dynamic@CurrentValue[assyncnb, {"PendingWolframCloudTasks", "Save"}]], FontSize ->24]

NotebookClose[assyncnb]

WolframCloudDocumentQ[]

Determines if a NotebookObject is stored on the cloud

Building block for interface creation

Looks like this:

FEPrivate`WolframCloudDocumentQ[nb_NotebookObject]

Example

Column[{"Where is this document stored?",PaneSelector[{False->"Local", True->"Cloud"}, Dynamic@FEPrivate`WolframCloudDocumentQ[EvaluationNotebook[]]]}]

NotebookSave[] cont...

NotebookSave now accepts a CloudObject as the destination

Can be used with a new or pre-existing CloudObject

The operation is performed synchronously (* the data will be sent to the server before the function completes *)

Example

savenb = GenerateExampleNotebook[];
NotebookSave[savenb, FileNameJoin[{CloudDirectory[], "Tech Conference 2014", "NotebookSave.nb"}]];
NotebookClose@savenb;

CDFDeploy

Programmatically deploy content straight to the cloud

v10.0 - v10.0.2

Module[{localFileName= FileNameJoin[{$TemporaryDirectory, "CDFDeploy.cdf"}], 
cloudObject = FileNameJoin[{CloudDirectory[], "Tech Conference 2014", "CDFDeploy.cdf"}],deploynb, deploycobj},

	deploynb = NotebookPut[Notebook[{ToBoxes@gameBoard[]}, WindowTitle->"Deal Me In!"]];
	CDFDeploy[localFileName,deploynb, "Standalone"->True];
	NotebookClose[deploynb];
	CopyFile[localFileName,cloudObject];
	  DeleteFile@localFileName;
	SetOptions[cloudObject, Permissions->"Public"];
	NotebookOpen[cloudObject];
]

In a future update

deploynb = NotebookPut[Notebook[{ToBoxes@gameBoard[]}, WindowTitle->"Deal Me In!"]];
deploycobj=CDFDeploy[FileNameJoin[{CloudDirectory[], "Tech Conference 2014", "CDFDeploy.cdf"}],deploynb, "Standalone"->True];
SetOptions[deploycobj, Permissions->"Public"];
NotebookClose[deploynb];
NotebookOpen[deploycobj];

In Product Handling of CloudObjects

NotebookLocate[]

Open a document stored on the cloud and jump to the supplied Cell Tag

NotebookLocate[{FileNameJoin[{CloudDirectory[], "Tech Conference 2014", "NotebookLocate.nb"}], "LastParagraph"}];

Hyperlink[]

An interactive method to open a CloudObject in a web browser (maybe....  still debating if this should open in the client by default)

Hyperlink["Manipulate examples",FileNameJoin[{CloudDirectory[], "Tech Conference 2014", "Manipulate.nb"}]]

SystemOpen[]

Programmatically open a CloudObject in a web browser

SystemOpen[FileNameJoin[{CloudDirectory[], "Tech Conference 2014", "Manipulate.nb"}]]

Out of Product Handling of CloudObjects

Wolfram Cloud Object Protocol

Mathematica and Wolfram Desktop will register themselves as handlers

Looks like this:

wolfram+cloudobject:www.wolframcloud.com/objects/dcb8bd43-97ec-467e-850b-e14364281cf3

Examples

This will open in the client instead of the web browser

SystemOpen[ToCloudObjectProtocol@FileNameJoin[{CloudDirectory[], "Tech Conference 2014", "Manipulate.nb"}]];

And you can put them in any hyperlink tag

SystemOpen[FileNameJoin[{NotebookDirectory[], "CloudObjectProtocol.html"}]]

Related Talks & Workshops

Manipulate Secrets Revealed - Lou D’Andria
Today  5:00 PM - 5:30 PM
Little Chief

Workshop: Programming Cloud - Joel Klein and Tom Wickam-Jones
Thursday 4 : 00 PM - 5 : 00 PM
Spartan/Golden Gopher

Wolfram Cloud - Jan Poeschko
Friday 10:30 AM - 11:30 AM
Fighting Illini

What' s New in CDF - Andre Kuzniarek
Friday 11:30 AM - 12:00 PM
Fighting Illini

Questions???

Initialization

ToCloudObjectProtocol[obj_CloudObject]:= StringReplace[First@obj, "https://"->"wolfram+cloudobject:"]

GenerateExampleNotebook[]:=NotebookPut[Notebook[{Cell["New Section","Section"], Cell["New Subsection","Subsection"], Cell["Lorem ipsum dolor sit amet, consectetur adipiscing elit. In lacinia suscipit velit, vel pharetra massa. Fusce mollis scelerisque finibus. Suspendisse finibus, purus ut mattis ultricies, mi ipsum tempus lorem, pulvinar tristique lacus ante sit amet urna. Aliquam dignissim vestibulum fermentum. Mauris egestas tincidunt metus, vitae ultrices neque consequat sed. Integer enim libero, ultricies sed luctus sit amet, iaculis vel neque. Etiam at lectus facilisis, dapibus tellus vitae, tincidunt diam. Duis feugiat lacinia nulla ut eleifend.","Text"], Cell["Next Subsection","Subsection"], Cell["Nulla malesuada ante nibh, a ornare mauris gravida in. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Integer in placerat urna, non accumsan ante. Mauris vitae viverra eros. Pellentesque erat diam, posuere eget mi semper, elementum efficitur eros. Nulla facilisi. In at rutrum arcu.", "Text"],
Cell["Suspendisse a nisi id elit scelerisque elementum eget et massa. Etiam sollicitudin mi non velit accumsan porttitor. Donec in tristique arcu, vitae volutpat magna. Nunc lacinia nisl et purus tempor, in hendrerit metus convallis. Proin euismod ut tellus eget rhoncus. Etiam blandit facilisis orci, non finibus velit aliquet blandit. Mauris dapibus ornare sodales. Nullam vitae lobortis enim. Fusce tempus lectus sed ligula facilisis fermentum. Duis eleifend leo a sapien condimentum pretium. Vestibulum dignissim ornare massa. Praesent sollicitudin dui dictum eros consectetur aliquam. ", "Text"]},WindowTitle->"Example Document"]];